#include "GameInfo.h"
#include <string>

using namespace std;

string GameInfo::state_names[5] = {"VIC","NSW","SA","QLD","WA"};

GameInfo::GameInfo(void)
{
	day = 0;
	total_states = 5;
	current_state_index = 0;
	init_market();
	init_states();
}

void GameInfo::init_market()
{
	// Initialise a base market price for all commodities
	GameInfo::set_market["Car"] = 50000.0;
	GameInfo::set_market["TV"] = 950.0;
	GameInfo::set_market["Computer"] = 1200.0;
	GameInfo::set_market["Shoes"] = 150.0;
	GameInfo::set_market["Watches"] = 100.0;
	GameInfo::set_market["Stereo"] = 23.50;
	GameInfo::set_market["Motorbike"] = 18750.0;
	GameInfo::set_market["Coffee machine"] = 210.0;
}

void GameInfo::init_player(string player_name)
{
	Player* np = new Player(player_name);
	current_player = np;
}

void GameInfo::init_states()
{
	map<string,float>* pSetMarket = &set_market;
	for (int x=0; x < get_total_states(); x++)
	{
		State new_state = State(state_names[x]);
		new_state.set_local_market(pSetMarket);
		states[x] = new_state;
	}
}

State* GameInfo::get_state_current()
{
	return &states[current_state_index];
}

State* GameInfo::get_state_index(int i)
{
	return &states[i];
}

string GameInfo::set_current_state_index(int new_index)
{
	current_state_index = new_index;
	return states[current_state_index].get_name(); 
}

void GameInfo::set_day_limit(int new_day_limit)
{
	day_limit = new_day_limit;
}

void GameInfo::next_day()
{
	day++;
	for (int x=0; x < get_total_states(); x++)
	{
		states[x].new_local_market();
	}
	// make new prices for market
	// refresh a market list
	// put up day count
}

GameInfo::~GameInfo(void)
{
}
